﻿using System;
using NUnit.Framework;
  

namespace TP1
{
   
    public class Calculator_test
    {
        [Test]
        public void TestHelloWorld()
        {
            Assert.AreEqual(true, true);
        }
        [Test]
        public void TestHelloWorldFailed()
        {
            Assert.AreEqual(true, false);
        }
        [Test]
        public void TestSingleNumber()
        {
            Calculator c = new Calculator();
            string expression = "3";
            //Action
            DoAction(expression, 3);
        }
        [Test]
        public void TestSingleNumberForFreeNumber()
        {
            Calculator c = new Calculator();
            int expected = new Random().Next(10);

            //Action
            DoAction(expected.ToString(), expected);

        }
        [Test]
        public void TestDoubleNumber()
        {
            //arrange
            string expression = "3+4";
            int expected = 7;

            //Action
            DoAction(expression, expected);

        }

        [Test]
        public void TestComplexDoubleNumber()
        {
            //arrange
            string expression = "33+4";
            int expected = 37;

            //Action
            DoAction(expression, expected);
        }

        [Test]
        public void TestMoreComplexDoubleNumber()
        {
            //arrange
            string expression = "33-4";
            int expected = 29;

            //Action
            DoAction(expression, expected);
        }
        [Test]
        public void TestMoreComplexDoubleNumber_chengfa()
        {
            //arrange
            string expression = "33*4";
            int expected = 132;

            //Action
            DoAction(expression, expected);
        }

        [Test]
        public void TestMoreNumbers()
        {
            //arrange
            string expression = "3+4-5+6";
            int expected = 8;

            //Action
            DoAction(expression, expected);
        }
        [Test]
        public void TestMoreComplexNumbers()
        {
            //arrange
            string expression = "33+4-55+6";
            int expected =-12;

            //Action
            DoAction(expression, expected);
        }

        private void DoAction(string expression, int expected)
        {
            Calculator c = new Calculator();
            int result = c.Calculate(expression);

            //assert
            Assert.AreEqual(expected, result);
        }

    }
}
